import 'package:flutter/material.dart';
import 'package:flutter_app/components/radiusContainer.dart';
import 'package:flutter_app/generated/l10n.dart';
class DefiModule extends StatefulWidget {
  @override
  _DefiModuleState createState() => _DefiModuleState();
}
Widget greyText(String text){
  return Text(text,style: TextStyle(color: Colors.grey, fontSize: 13));
}
List<Widget> getModule(context) {
  return [1, 1, 1, 1].map((item) {
    return Container(
      width: 230,
      margin: const EdgeInsets.only(right: 15),
      padding: EdgeInsets.all(15.0),
      color: Colors.grey.withOpacity(0.06),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            children: [
              Image.asset(
                "assets/images/ic_btc.png",
                width: 20,
                height: 20,
              ),
              SizedBox(width: 5),
              Text(
                //定期精选
                S.of(context).fixed_term,
                style: TextStyle(
                    fontWeight: FontWeight.w500,
                    color: Colors.black.withOpacity(0.7)),
              ),
            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    '0.1~16%',
                    style: TextStyle(fontWeight: FontWeight.w600, fontSize: 19),
                  ),
                  //apy 基准收益率
                  greyText(S.of(context).apy),
                ],
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    '0.1~16%',
                    style: TextStyle(fontWeight: FontWeight.w600, fontSize: 18),
                  ),
                  //投资期限
                  greyText(S.of(context).tenor),
                ],
              ),
            ],
          )
        ],
      ),
    );
  }).toList();
}

class _DefiModuleState extends State<DefiModule> {
  @override
  Widget build(BuildContext context) {
    return RadiusContainer(
      radius: 5.0,
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                'DeFi '+S.of(context).mining,
                style: TextStyle(fontWeight: FontWeight.w500, fontSize: 17),
              ),
            ],
          ),
          Container(
            height: 100,
            margin: EdgeInsets.only(top: 15),
            child: ListView(
                scrollDirection: Axis.horizontal, children: getModule(context)),
          )
        ],
      ),
    );
  }
}
